/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function validateEmail(email)
{
    var atpos=email.indexOf("@");
    var dotpos=email.lastIndexOf(".");
    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=email.length)
    {
        return false;
  
    }
    return true;
}

function validatePassword(password){
    if (password.length < 6)
        return false;
    return true;
}

function validateRetypePassword(password, retypePassword){
    
    if (password != retypePassword)
        return false;
    return true;
}

function validateFirstName(firstName){
    if (firstName.length > 25 || firstName.length <=1)
        return false
    return true;
}

function validatelastName(lasttName){
    if (lasttName.length > 30 || lasttName.length <=1)
        return false
    return true;
}

function validateSecurityQuestion(securityQuestion){
    if (securityQuestion.length > 45 || securityQuestion.length <=2)
        return false
    return true;
}

function validateSecurityAnswer(securityAnswer){
    if (securityAnswer.length > 45 || securityAnswer <=2)
        return false
    return true;
}

function validateBirthDate(birthMonth, birthDay, birthYear){
    
    
    var res;
    if (birthMonth == "null" || birthDay == "null" || birthYear == "null")
        res = "true";
    else
        res = "false";
    if ( res=="true" )
        
        return false;
    
    return true;
}

function validateAll(email, firstName, lastName, SecurityQuestion, securityAnswer, password, retypePassword, birthMonth, birthDay, birthYear){
    if (!validateFirstName(firstName) || !validatelastName(lasttName) || !validateEmail(email) || validateSecurityQuestion(securityQuestion) || !validateSecurityAnswer(securityAnswer) || !validatePassword(password) || !validateRetypePassword(password, retypePassword) || !validateBirthDate(birthMonth, birthDay, birthYear)){
        return false;
        
    }
    return true;
}